# Selenium 自动化浏览与表单填充
# 1st
import selenium
# from selenium import webdriver
# from selenium.webdriver.chrome.service import Service
# from webdriver_manager.chrome import ChromeDriverManager

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

service = Service(ChromeDriverManager().install())

wd = webdriver.Chrome(service=service)

wd.get('https://www.bilibili.com/')

input('等待回车键结束程序')

# 2nd
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

# 使用 webdriver-manager 自动下载并管理驱动
service = Service(ChromeDriverManager().install())

# 创建 WebDriver 实例
driver = webdriver.Chrome(service=service)

# 打开指定 URL
url = "http://hmshop-test.itheima.net/Home/user/login.html"
driver.get(url)

# 通过 id 定位手机号输入框并输入内容
driver.find_element(By.ID, "username").send_keys("13012345678")

# 通过 name 定位密码输入框并输入内容
driver.find_element(By.NAME, "password").send_keys("123456")

# 通过 id 定位验证码输入框并输入内容
driver.find_element(By.ID, "verify_code").send_keys("8888")

input('等待回车键结束程序')